import requests


class CommonRequest:

    # Post 请求方式
    def post_method(self, url, data, headers):
        response = requests.post(url=url, data=data, headers=headers)
        return response

    # Get 请求方式
    def get_method(self, url, data, headers):
        response = requests.get(url=url, data=data, headers=headers)
        return response

    # Put 请求方式
    def put_method(self, url, data, headers):
        response = requests.put(url=url, data=data, headers=headers)
        return response

    # Delete 请求方式
    def delete_method(self, url, data, headers):
        response = requests.delete(url=url, headers=headers, params=data)
        return response

    # 如果还有更多的请求方式另行封装
    # 选择请求方式
    def choose_method(self, method, url, data, headers):
        # base_url = self.create_headers.get_host()
            if method == 'post':
                response = self.post_method(url, data, headers)
            elif method == 'get':
                response = self.get_method(url, data, headers)
            elif method == 'put':
                response = self.put_method(url, data, headers)
            else:
                response = self.delete_method(url, data, headers)
            return response


if __name__ == '__main__':
    common_requests = CommonRequest()

